<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="学生专业" prop="dept_name">
        <el-input
          v-model="queryParams.dept_name"
          placeholder="请输入学生专业"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学生学号" prop="sport_name_user">
        <el-input
          v-model="queryParams.sport_name_user"
          placeholder="请输入学生学号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      :row-class-name="tableRowClassName"
      v-loading="loading"
      :data="informationList"
    >
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="运动会届" align="center" prop="sportDename" />
      <el-table-column
        label="学生专业"
        align="center"
        prop="dept_name"
      ></el-table-column>
      <el-table-column label="学生姓名" align="center" prop="nick_name" />

      <el-table-column label="学生手机号" align="center" prop="phonenumber" />
      <el-table-column label="学生学号" align="center" prop="sport_name_user" />

      <el-table-column
        label="运动会名称"
        align="center"
        prop="declare_xm_name"
      />
      <el-table-column
        label="运动会主题"
        align="center"
        prop="sport_xm_theme"
      />
      <el-table-column label="我的成绩" align="center" prop="sportGrade" />
      <el-table-column label="获得积分" align="center" prop="sportGradeA"/>
      <el-table-column label="我的获奖" align="center" prop="sportPalm" />
      <el-table-column label="我的获奖备注" align="center" prop="sportPalmA" />

      <el-table-column
        label="获奖时间"
        align="center"
        prop="create_time"
        width="180"
        sortable
      >
        <!-- <template slot-scope="scope">
          <span>{{ parseTime(scope.row.create_time, "{y}-{m}-{d}") }}</span>
        </template> -->
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
<style>
.el-table .warning-row {
  background: rgb(212, 211, 117);
}

.el-table .success-row {
  background: #f0f9eb;
}
</style>
<script>
import { querystudentgradelist } from "@/api/sportferees/ferees";

export default {
  name: "Information",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 运动会届表格数据
      informationList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        dept_name: null,
        sport_name_user: null,
      },
      // 表单参数
      form: {},

      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //css样式
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 1) {
        return "warning-row";
      } else if (rowIndex % 2 == 0) {
        return "success-row";
      }
      return "";
    },

    getList() {
      this.loading = true;
      querystudentgradelist(this.queryParams).then((response) => {
        console.log(response.rows);
        this.informationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    // 表单重置
    reset() {
      this.form = {
        declareUid: null,
        sportListId: null,
        sportNameAccount: null,
        sportNameUser: null,
        declareXmName: null,
        sportXmTheme: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        sportDename: null,
        sportGrade: null,
        sportGradeA: null,
        sportPalm: null,
        sportPalmA: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        dept_name: null,
        nick_name: null,
        phonenumber: null,
        sport_name_user: null,
        declare_xm_name: null,
        sport_xm_theme: null,
        sportGrade: null,
        sportGradeA: null,
        sportPalmA: null,
        createTime: null,
        sportPalm: null,
        create_time: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "/sportferees/ferees/gradelistexport",
        {
          ...this.queryParams,
        },
        `information_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
